#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <iostream>

using namespace std ;

int main ( )
{
	int sockfd ;
	int len ;
	struct sockaddr_in address ;
	int result ;
	char ch = 'A' ;

	sockfd = socket(AF_INET, SOCK_STREAM, 0) ;
	address.sin_family = AF_INET;
	address.sin_addr.s_addr = inet_addr("192.158.125.209") ;
	address.sin_port = htons(9734) ;
	len = sizeof(address) ;

	result = connect(sockfd, (struct sockaddr *)&address, len);
	if ( result == -1 )
	{
		perror("oops: client1") ;
		exit(1) ;
	}

	string command = "Send T 104" ;
	while(1)
	{
		write(sockfd, command.c_str() , command.size()+1 ) ;
		read(sockfd, &ch, 1) ;
		cout<< "Char from server = " << ch << endl ;
		sleep(10) ;
	}
	close(sockfd) ;
	
	return 0 ;
}
